<div class="content-section introduction">
    <div class="feature-intro">
        <h1>Chips</h1>
        <p>Chips is used to enter multiple values on an input field.</p>
    </div>
    <app-demoActions github="chips" stackblitz="chips-demo"></app-demoActions>
</div>

<div class="content-section implementation p-fluid">
    <div class="card">
        <h5>Basic</h5>
        <p-chips [(ngModel)]="values1"></p-chips>

        <h5>Comma Separator</h5>
        <p-chips [(ngModel)]="values2" separator=","></p-chips>
        
        <h5>Template</h5>
        <p-chips [(ngModel)]="values3">
            <ng-template let-item pTemplate="item">
                {{item}} - (active) <i class="pi pi-user ml-2"></i>
            </ng-template>
        </p-chips>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;ChipsModule&#125; from 'primeng/chips';
</app-code>

            <h5>Getting Started</h5>
            <p>Chips requires an array as its model.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-chips [(ngModel)]="values"&gt;&lt;/p-chips&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MyModel &#123;

    values: string[];

&#125;
</app-code>
            <h5>Model Driven Forms</h5>
            <p>Chips can be used in a model driven form as well.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-chips formControlName="cities"&gt;&lt;/p-chips&gt;
</app-code>

            <h5>Custom Content</h5>
            <p>A chip is customized using a <i>ng-template</i> element where the value is passed as the implicit variable.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-chips [(ngModel)]="values"&gt;
    &lt;ng-template let-item pTemplate="item"&gt;
        &#123;&#123;item&#125;&#125; - (active) &lt;i class="pi pi-user ml-2"&gt;&lt;/i&gt;
    &lt;/ng-template&gt;
&lt;/p-chips&gt;
</app-code>
            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Default</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>field</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the property to display on a chip.</td>
                        </tr>
                        <tr>
                            <td>max</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Maximum number of entries allowed.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the element.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the element.</td>
                        </tr>
                        <tr>
                            <td>placeholder</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Advisory information to display on input.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>ariaLabelledBy</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Establishes relationships between the component and label(s) where its value should be one or more element IDs.</td>
                        </tr>
                        <tr>
                            <td>allowDuplicate</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to allow duplicate values or not.</td>
                        </tr>
                        <tr>
                            <td>inputStyle</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the input field.</td>
                        </tr>
                        <tr>
                            <td>inputStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the input field.</td>
                        </tr>
                        <tr>
                            <td>addOnTab</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to add an item on tab key press.</td>
                        </tr>
                        <tr>
                            <td>addOnBlur</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to add an item when the input loses focus.</td>
                        </tr>
                        <tr>
                            <td>separator</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Separator char to add an item when pressed in addition to the enter key. Currently only possible value is ","</td>
                        </tr>
                        <tr>
                            <td>showClear</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When enabled, a clear icon is displayed to clear the value.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Parameters</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onAdd</td>
                            <td>originalEvent: Browser event <br >
                                value: Added item value
                            </td>
                            <td>Callback to invoke when a value is added.</td>
                        </tr>
                        <tr>
                            <td>onRemove</td>
                            <td>originalEvent: Browser event <br >
                                value: Added item value
                            </td>
                            <td>Callback to invoke when a value is removed.</td>
                        </tr>
                        <tr>
                            <td>onChipClick</td>
                            <td>originalEvent: Browser event <br >
                                value: Clicked item value
                            </td>
                            <td>Callback to invoke when a chip is clicked.</td>
                        </tr>
                        <tr>
                            <td>onFocus</td>
                            <td>originalEvent: Browser event</td>
                            <td>Callback to invoke when a input is focused.</td>
                        </tr>
                        <tr>
                            <td>onBlur</td>
                            <td>originalEvent: Browser event</td>
                            <td>Callback to invoke when a input loses focus.</td>
                        </tr>
                        <tr>
                            <td>onClear</td>
                            <td>-</td>
                            <td>Callback to invoke when input field is cleared.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Templates</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>chip</td>
                            <td>$implicit: value</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-chips</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-chips-token</td>
                            <td>Chip element container.</td>
                        </tr>
                        <tr>
                            <td>p-chips-token-icon</td>
                            <td>Icon of a chip.</td>
                        </tr>
                        <tr>
                            <td>p-chips-token-label</td>
                            <td>Label of a chip.</td>
                        </tr>
                        <tr>
                            <td>p-chips-input-token</td>
                            <td>Container of input element.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/chips" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-chips-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Basic&lt;/h5&gt;
&lt;p-chips [(ngModel)]="values1" &gt;&lt;/p-chips&gt;

&lt;h5&gt;Comma Separator&lt;/h5&gt;
&lt;p-chips [(ngModel)]="values2" separator=","&gt;&lt;/p-chips&gt;

&lt;h5&gt;ng-template&lt;/h5&gt;
&lt;p-chips [(ngModel)]="values3"&gt;
    &lt;ng-template let-item pTemplate="item"&gt;
        &#123;&#123;item&#125;&#125; - (active) &lt;i class="pi pi-user ml-2"&gt;&lt;/i&gt;
    &lt;/ng-template&gt;
&lt;/p-chips&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ChipsDemo &#123;

    values1: string[];
    
    values2: string[];

    values3: string[];
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-chips-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
